package com.snail.billing.net;

import java.util.List;

import org.apache.http.NameValuePair;

public abstract class BillingRegisterArrayHttpSession extends BillingHttpSession {

	@Override
	public void buildParamPair() {
		BillingSecurity security = getSecurity();
		addParamPair("accessId", security.accessId);
		addParamPair("accessPasswd", security.accessPasswd);
		addParamPair("accessType", security.accessType);
		for (NameValuePair pair : getBillingPairList()) {
			addParamPair(pair.getName(), pair.getValue());
		}
		addParamPair("sVerifyStr", buildVerifyStr(security, getBillingPairList()));
	}

	protected String buildVerifyStr(BillingSecurity security, List<NameValuePair> list) {
		StringBuilder builder = new StringBuilder();
		builder.append(security.accessId);
		builder.append(security.accessPasswd);
		builder.append(security.accessType);
		for (NameValuePair pair : list) {
			builder.append(pair.getValue());
		}
		builder.append(security.seed);
		String origin = builder.toString();
		return BillingEncode.MD5(origin);
	}

}
